// myInfo.js

Page({
  data: {
    counter: 0,
    text: "init"
  },
  tap: function() {
    this.setData({
      counter: this.data.counter + 1
    })

    let that = this
    console.log("send request!")
    // const url = 'https://mock.com/data'
    const url = "http://localhost:8081/"
    wx.request({
      url: url,
      header: {
        'content-type': 'application/json' // 默认值
      },
      success(res) {
        console.log(res)
        let data = res.data.data || res.data
        if(res.statusCode === 200) {
          if(data.string) {
            that.setData({text: data.string})
          }
        }
      }
    })
  }
})